<?php


namespace Part26_SharingElementMode\Code2;


class FlyweightFactory
{
    /**
     * @var Flyweight[]
     */
    private $flyweights;

    public function __construct()
    {
        $this->flyweights['x'] = new ConcreteFlyweight();
        $this->flyweights['y'] = new ConcreteFlyweight();
        $this->flyweights['z'] = new ConcreteFlyweight();
    }

    public function getFlyWeight($key)
    {
        return $this->flyweights[$key];
    }
}